<?php

function getArianeParent($child)
{
	
	$parentschilds = array(	"ajoutbienproprio.php" => "proprietaire.php",
							"ajouterlocation.php" => "proprietaire.php",
							"contactOwner.php" => "location.php",
							"demandeReservation.php" => "location.php",
							"gererbienproprio.php" => "proprietaire.php",
							"gererlocationproprio.php" => "proprietaire.php",
							"index.php" => "",
							"location.php" => "locations.php",
							"propriointermed.php" => "proprietaire.php"
						   );
	
	foreach ($parentschilds as $path=>$parent)
	{
		if ($path == $child)
		{
			return $parent;
		}
	}
	
	return "index.php";
	
}

function getArianeName($person)
{
	
	$names['Fr'] = array(	"administrateur.php" => "Espace Administrateur",
							"ajoutbienproprio.php" => "Ajouter un bien",
							"ajouterlocation.php" => "Ajouter une location",
							"client.php" => "Espace Client",
							"contactOwner.php" => "Contacter un propriétaire",
							"demandeReservation.php" => "Déposer une réservation",
							"editProfile.php" => "Editer son profil",
							"gererbienproprio.php" => "Gérer un bien",
							"gererlocationproprio.php" => "Gérer les locations",
							"historyClient.php" => "Voir son historique de locations",
							"intermediaire.php" => "Espace Intermédiaire",
							"login.php" => "Se connecter",
							"logout.php" => "Se déconnecter",
							"promos.php" => "Promotions",
							"proprietaire.php" => "Espace Propriétaire",
							"propriointermed.php" => "Gérer les intermédiaires"
						);
							
	$names['En'] = array(	"administrateur.php" => "Administrator Space",
							"ajoutbienproprio.php" => "Add a good",
							"ajouterlocation.php" => "Add a location",
							"client.php" => "Client Space",
							"contactOwner.php" => "Contact an owner",
							"demanderReservation.php" => "Send a demand",
							"editProfile.php" => "Edit your profile",
							"gererbienproprio.php" => "Manage a good",
							"gererlocationproprio.php" => "Manage locations",
							"historyClient.php" => "See your history",
							"index.php" => "Home",
							"inscription.php" => "Register",
							"intermediaire.php" => "Middleman Space",
							"promos.php" => "Special Offers",
							"proprietaire.php" => "Owner Space",
							"propriointermed.php" => "Manage Middlemen"
						);
	
	foreach ($names[$_SESSION['lang']] as $name=>$ArianeName)
	{
		if ($name == $person)
		{
			return $ArianeName;
		}
	}
	
	$automatedName = explode(".",$person);
	$automatedName = ucfirst($automatedName[0]);
	
	return $automatedName;
	
}

function getArianeGenealogy($firstChild = "")
{
	
	if ($firstChild == "")
	{
		$firstChild = explode("/",$_SERVER["PHP_SELF"]);
		$firstChild = $firstChild[count($firstChild)-1];
	}

	$family = array();
	$return = "<span id='ArianeSpan'>";

	$page = $firstChild;
	$child = $page;

	do
	{
		$parent = getArianeParent($child);	
		$family[] = $parent;
		$child = $parent;
	} while ($parent != "");

	foreach (array_reverse($family) as $arianeElement)
	{
		$return .= '<a href="'.$arianeElement.'">'.getArianeName($arianeElement)."</a> > ";
	}

	return $return.'<a href="'.$page.'">'.getArianeName($page).'</a></span>';

}

?>
